﻿using System;
using DC2010.Objects;

namespace DC2010
{
    public class Attributes : ICloneable
    {
        /// <summary>
        /// This value represents how much damage a champion can take before dying.
        /// </summary>
        /// <remarks>You can regain Health points by sleeping and drinking healing potions. Health also naturally increases over time, but slowly.</remarks>
        public CurrentNormal Health { get; set; }

        public CurrentNormal Mana { get; set; }
        /// <summary>
        /// This value represents the champion's ability to overcome fatigue. It decreases when you walk and fight and also when you are hungry or thirsty. If this value is equal to zero, any more activity will decrease health.
        /// </summary>
        /// <remarks>You can regain Stamina points by sleeping and drinking Stamina potions. Stamina also naturally increases over time, but slowly.</remarks>
        public CurrentNormal Stamina { get; set; }
        /// <summary>
        /// It is used during combat and its value is changed each time you use it. The value increases when you are unlucky and decreases when you are lucky.For example, if a champion would miss a hit, his Luck can help him still succeed. In this case, the Luck value is decreased.
        /// This value is modified by some items: a Rabbit's Foot will increase it by 10, while cursed items will decrease it by 3.
        /// </summary>
        public CurrentNormal Luck { get; set; }
        /// <summary>
        /// This value determines the load a champion can carry, how far items can be thrown and how much damage is done by melee attacks.
        /// </summary>
        public CurrentNormal Strength { get; set; }
        /// <summary>
        /// This value determines the accuracy of missiles and the odds of hitting opponents in combat. It also helps the champion to avoid or reduce physical damage.
        /// </summary>
        public CurrentNormal Dexterity { get; set; }
        public CurrentNormal Intelligence { get; set; }
        /// <summary>
        /// This value is important for spellcasters as it determines their ability to master Magick. It also determines the speed of Mana recovery.
        /// </summary>
        public CurrentNormal Wisdom { get; set; }
        /// <summary>
        /// This value determines how quickly a champion heals and regains Stamina as wall as his poison resistance. It also helps to reduce damage.
        /// </summary>
        public CurrentNormal Vitality { get; set; }


        public CurrentNormal AntiMagic { get; set; }
        public CurrentNormal AntiFire { get; set; }

        /// <summary>
        /// These two values represent how hungry and thursty a champion is. Food and Water values are decreased to regenerate Stamina and Health. When these values reach zero, the champion is starving: his Stamina and health decrease until he eats, drinks or dies.
        /// </summary>
        public CurrentNormal Food { get; set; }
        /// <summary>
        /// These two values represent how hungry and thursty a champion is. Food and Water values are decreased to regenerate Stamina and Health. When these values reach zero, the champion is starving: his Stamina and health decrease until he eats, drinks or dies.
        /// </summary>
        public CurrentNormal Water { get; set; }

        public Attributes()
        {
            Health = new CurrentNormal();
            Mana = new CurrentNormal();
            Stamina = new CurrentNormal();
            Luck = new CurrentNormal();
            Strength = new CurrentNormal();
            Dexterity = new CurrentNormal();
            Intelligence = new CurrentNormal();
            Wisdom = new CurrentNormal();
            Vitality = new CurrentNormal();
            AntiFire = new CurrentNormal();
            AntiMagic = new CurrentNormal();
            Food = new CurrentNormal(1500,1500);
            Water = new CurrentNormal(1500,1500);
        }

        public CurrentNormal this[int index]
        {
            
            get
            {
                // 70 = [0] Luck??
                // 73 = [1] Strength
                // 76 = [2] Dexterity
                // 79 = [3] Wisdom    
                // 82 = [4] Vitality  
                // 85 = [5] AntiMagic 
                // 88 = [6] AntiFire  

                switch (index)
                {
                    case 0:
                        return Luck;
                    case 1:
                        return Strength;
                    case 2:
                        return Dexterity;
                    case 3:
                        return Wisdom;
                    case 4:
                        return Vitality;
                    case 5:
                        return AntiMagic;
                    case 6:
                        return AntiFire;
                }

                return null;
            }

        }


        #region ICloneable Members

        public object Clone()
        {
            Attributes atts = new Attributes();
            atts.Health = (CurrentNormal)Health.Clone();
            atts.Mana = (CurrentNormal)Mana.Clone();
            atts.Stamina = (CurrentNormal)Stamina.Clone();

            atts.Luck = (CurrentNormal)Luck.Clone();
            atts.Strength = (CurrentNormal)Strength.Clone();
            atts.Dexterity = (CurrentNormal)Dexterity.Clone();
            atts.Intelligence = (CurrentNormal)Intelligence.Clone();
            atts.Wisdom = (CurrentNormal)Wisdom.Clone();
            atts.Vitality = (CurrentNormal)Vitality.Clone();
            atts.AntiFire = (CurrentNormal)AntiFire.Clone();
            atts.AntiMagic = (CurrentNormal)AntiMagic.Clone();
            atts.Food = (CurrentNormal)Food.Clone();
            atts.Water = (CurrentNormal)Water.Clone();

            return atts;
        }

        #endregion
    }
}
